import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { ProductCategoryApiService } from 'src/app/api/product-category-api.service';
import { ProductCate } from 'src/app/model/proudctCate';

@Injectable({
  providedIn: 'root'
})
export class ProductCateResolverService implements Resolve<ProductCate>{

  constructor(
    private cateApi:ProductCategoryApiService,

  ) { }
  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): ProductCate | Observable<ProductCate> | Promise<ProductCate> {
    return this.cateApi.fetchItem(route.queryParams['id']);
  }
}
